
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>Chemical Properties Users Guide &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Sources of Data in ChemData.csv" href="../modules/chem_data.html" />
    <link rel="prev" title="Seawater Module Users Guide" href="seawater.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="chemical-properties-users-guide">
<h1>Chemical Properties Users Guide<a class="headerlink" href="#chemical-properties-users-guide" title="Permalink to this headline">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Release</dt>
<dd class="field-odd"><p>2.1</p>
</dd>
<dt class="field-even">Date</dt>
<dd class="field-even"><p>Jun 05, 2020</p>
</dd>
</dl>
<div class="section" id="scripts">
<h2>Scripts<a class="headerlink" href="#scripts" title="Permalink to this headline">¶</a></h2>
<p>the <code class="docutils literal notranslate"><span class="pre">TAMOC</span></code> files associated with chemical properties data include the
following</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../modules/chem_data.html">Sources of Data in ChemData.csv</a></li>
<li class="toctree-l1"><a class="reference internal" href="../autodoc/chem/chemical_properties.load_data.html">chemical_properties.load_data</a></li>
</ul>
</div>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<p>The main purpose of this script is to load in the default chemical property
data in <code class="docutils literal notranslate"><span class="pre">./data/ChemData.csv</span></code> and to store that data in a Python dictionary,
available to other programs. This script can also be used to import
user-defined chemical properties data in other <code class="docutils literal notranslate"><span class="pre">.csv</span> <span class="pre">files</span></code>. Within
<code class="docutils literal notranslate"><span class="pre">TAMOC</span></code> this script is generally not used by the user; rather, the class
objects, methods, and functions in the <cite>dbm</cite> module provides a fluid interface
to these databases.</p>
</div>
<div class="section" id="usage-within-tamoc">
<h2>Usage within <code class="docutils literal notranslate"><span class="pre">TAMOC</span></code><a class="headerlink" href="#usage-within-tamoc" title="Permalink to this headline">¶</a></h2>
<p>To load the data, simply import the script and optionally assign a new
namespace for storing the databases:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;</span> <span class="kn">import</span> <span class="nn">chemical_properties</span> <span class="k">as</span> <span class="nn">chem</span>
</pre></div>
</div>
<p>After import, two new dictionaries will be created, one with the properties
(called <cite>chem.data</cite>) and another with the units (called <cite>chem.units</cite>).  The
<cite>chem.data</cite> dictionary is double-nested, with the first set of keys choosing
a chemical component, and the second set of keys choosing a particular
property.</p>
<p>As an example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;</span> <span class="n">chem</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
<span class="p">[</span><span class="s1">&#39;benzene&#39;</span><span class="p">,</span>
 <span class="s1">&#39;n-decane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;nitrogen&#39;</span><span class="p">,</span>
 <span class="s1">&#39;3-methylpentane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;hydrogen&#39;</span><span class="p">,</span>
 <span class="s1">&#39;neohexane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;carbon_monoxide&#39;</span><span class="p">,</span>
 <span class="s1">&#39;n-butane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;carbon_dioxide&#39;</span><span class="p">,</span>
 <span class="s1">&#39;ethylbenzene&#39;</span><span class="p">,</span>
 <span class="s1">&#39;isopentane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;isobutane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;propane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;n-heptane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;water&#39;</span><span class="p">,</span>
 <span class="s1">&#39;2-methylpentane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;n-pentane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;toluene&#39;</span><span class="p">,</span>
 <span class="s1">&#39;n-hexane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;neopentane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;oxygen&#39;</span><span class="p">,</span>
 <span class="s1">&#39;hydrogen_sulfide&#39;</span><span class="p">,</span>
 <span class="s1">&#39;argon&#39;</span><span class="p">,</span>
 <span class="s1">&#39;2-3-dimethylbutane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;ethane&#39;</span><span class="p">,</span>
 <span class="s1">&#39;sulfure_dioxide&#39;</span><span class="p">,</span>
 <span class="s1">&#39;methane&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>Focusing on the nested dictionary for one of these keys, we have:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;</span> <span class="n">chem</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;oxygen&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
<span class="p">[</span><span class="s1">&#39;B&#39;</span><span class="p">,</span> <span class="s1">&#39;dH_solR&#39;</span><span class="p">,</span> <span class="s1">&#39;dE&#39;</span><span class="p">,</span> <span class="s1">&#39;M&#39;</span><span class="p">,</span> <span class="s1">&#39;Pc&#39;</span><span class="p">,</span> <span class="s1">&#39;nu_bar&#39;</span><span class="p">,</span> <span class="s1">&#39;kh_0&#39;</span><span class="p">,</span> <span class="s1">&#39;omega&#39;</span><span class="p">,</span> <span class="s1">&#39;Tc&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>To access the value for one of these keys, just use the double-nested
index:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">chem</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;oxygen&#39;</span><span class="p">][</span><span class="s1">&#39;M&#39;</span><span class="p">]</span>    <span class="c1"># Molecular weight</span>
<span class="go">0.031998800000000001</span>
</pre></div>
</div>
<p>The <cite>chem.units</cite> database provides access to the units of each of these
variables.  Because the units are independent of the chemical, the units
database only includes the second dictionary of keys:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">chem</span><span class="o">.</span><span class="n">units</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
<span class="go">[&#39;Pc&#39;, &#39;nu_bar&#39;, &#39;Compound&#39;, &#39;kh_0&#39;, &#39;omega&#39;, &#39;B&#39;, &#39;dE&#39;, &#39;M&#39;, &#39;Tc&#39;, &#39;dH_solR&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">chem</span><span class="o">.</span><span class="n">units</span><span class="p">[</span><span class="s1">&#39;M&#39;</span><span class="p">]</span>
<span class="go">&#39;(kg/mol)&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="usage-to-import-user-defined-data">
<h2>Usage to Import User-Defined Data<a class="headerlink" href="#usage-to-import-user-defined-data" title="Permalink to this headline">¶</a></h2>
<p>It may often occur that the user needs to specify the properties of
compounds not in the default database.  The easiest way to do this is to
create a new database, for instance <code class="docutils literal notranslate"><span class="pre">./Inputs/my_data.csv</span></code> that contains
the needed compounds.  This can be done for instance with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;</span> <span class="n">data</span><span class="p">,</span> <span class="n">units</span> <span class="o">=</span> <span class="n">chemical_properties</span><span class="o">.</span><span class="n">load_data</span><span class="p">(</span><span class="s1">&#39;./Input/my_data.csv&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>In the discrete bubble model <cite>dbm</cite>, <code class="docutils literal notranslate"><span class="pre">TAMOC</span></code> imports the default data
base.  When the user creates a <cite>dbm</cite> object, there is the option to pass
a user-defined database.  If this is done, <cite>dbm</cite> looks in the user-defined
database first to find properties for compounds in a composition.  This
allows the user to also override the properties in the default database.
If the compound is not found in the user-defined database, then the <cite>dbm</cite>
object looks in the default database.  Hence, it is not necessary to repeat
any of the compounds in the default database when building a user-defined
database, unless one desires to override the default property values.</p>
</div>
</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="../user_manual.html">TAMOC User Manual</a><ul>
      <li>Previous: <a href="seawater.html" title="previous chapter">Seawater Module Users Guide</a></li>
      <li>Next: <a href="../modules/chem_data.html" title="next chapter">Sources of Data in ChemData.csv</a></li>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="../_sources/guides/chem.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>